package com.sinaapp.gavinzhang.GSpider.webaddress;

import com.caucho.hessian.client.HessianProxyFactory;
import com.sinaapp.gavinzhang.GSpider.common.IpUtil;
import com.sinaapp.gavinzhang.GSpider.common.RegisterUtil;
import com.sinaapp.gavinzhang.GSpider.management.Register;
import com.sinaapp.gavinzhang.GSpider.management.RegistrationCenter;
import com.sinaapp.gavinzhang.GSpider.management.Stub;

import java.io.*;
import java.rmi.Naming;
import java.util.UUID;

/**
 * @author zhangheng5
 * @date 2016/3/9
 * @description 测试
 */
public class TestGetURLManagementAndGetURL {


    public static int getProjectFileNumber(File file, String endsWith) throws IOException {
        int number = 0;
        if (file.exists()) {
            if (file.isDirectory()) {
                for (File subFile : file.listFiles()) {
                    number += getProjectFileNumber(subFile, endsWith);
                }
            } else if (file.isFile() && file.getName().endsWith(endsWith)) {
                BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
                while (br.readLine() != null) {
                    number += 1;
                }
            } else {
                System.out.println("===" + file.getAbsolutePath());
            }
        }
        return number;
    }

    public static void main(String[] args) throws IOException {
        //用法示例
        int num = getProjectFileNumber(new File("E:\\code\\idea\\GSpider\\src\\main\\java\\com\\sinaapp\\gavinzhang\\GSpider"), ".java");
        System.out.println(num);
    }
}
